<?php
/*
 * Created on 21/02/2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
class CoachDao {
    function loadAdmins() {
        $array = array ();
        $rs = executeQuery("select coach_id, name, password, type, email from coaches where type > 0");
        while ($row = mysql_fetch_row($rs)) {
            $coach = new Coach($row[0], $row[1], $row[2], $row[3], $row[4]);
            $array[$coach->id] = $coach;
        }

        return $array;
    }
    
    function findPlayOffAppearances($coachId) {
        $array = array();
        $rs = executeQuery("SELECT m.fk_season_id, m.match_type FROM matches m join teams t on fk_coach_id=$coachId " .
        		"join match_records h on m.home_record=h.match_record_id " .
        		"join match_records a on m.away_record=a.match_record_id " .
        		"where m.match_type in ('Final','Semi-Final') " .
        		"and (t.team_id=h.team_id or t.team_id=a.team_id)" .
        		"order by 2 desc, 1 desc");
        while ($row = mysql_fetch_row($rs)) {
        	$id = $row[0];
        	$array[$id] = $row[1];
        }

        return $array;
    }
}
?>
